import React, { useState, useEffect, useCallback } from 'react'
import axios from 'axios';
import { useNavigate } from 'react-router-dom';

export default function Shipin() {

    const navigate = useNavigate()
    //视频播放获取数据
    const [arr, setarr] = useState([]);
    const getall = useCallback(async () => {
        let data = await axios.get("http://localhost:3009/getstu")
        setarr(data.data.stu)
    }, [])
    //钩子函数
    useEffect(() => {
        getall()
    }, [getall])
    return (
        <div>
            {
                arr.map(item => {
                    // return  <NavBar onBack={back}>标题</NavBar>
                    return <div key={item._id} className='a2' onClick={() => { navigate(`/index/kitchen/jiankong`, { state: { item: [item] } }) }} >
                        {item.name}
                    </div>
                })
            }
        </div>
    )
}
